﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class FinanceCenter_FinanceIndex : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            this.lbUserName.Text =_Customer.CustomerName;
            BindAccountBaseInfo();
            BindanagerLoginInfo();
        }
    }

    #region Web 窗体设计器生成的代码

    override protected void OnInit(EventArgs e)
    {
        isRequestLogin = true;
        //RequestCompetences = Competences.BuildCompetencesList(Competences.Finance);
        RequestLoginPage = "FinanceCenter/FinanceIndex.aspx";

        base.OnInit(e);
    }

    #endregion

    private void BindAccountBaseInfo()
    {
        long RegTotal = 0;
        long DayRegCount = 0;
        double TotalGathering = 0;
        double PayTota = 0;
        double DayBuy = 0;
        double HistoryBuy = 0;
        double CurPlayRatio = 0;
        long TotalNumberOfCopies = 0;
        long DayTotalNumberOfCopies = 0;

        if (DAL.Procedures.P_GetAccountBaseInfo(ref RegTotal, ref DayRegCount, ref TotalGathering, ref PayTota, ref DayBuy, ref HistoryBuy, ref CurPlayRatio, ref TotalNumberOfCopies, ref DayTotalNumberOfCopies) < 0)
        {
            Shove._Web.JavaScript.Alert(this.Page, "数据库连接错误");

            return;
        }

        this.lbRegTotal.Text = RegTotal.ToString();
        this.lbDayRegCount.Text = DayRegCount.ToString();
        this.lblTotalGathering.Text = (Shove._Convert.StrToDouble(TotalGathering.ToString(), 0) == 0) ? "0.00" : Shove._Convert.StrToDouble(TotalGathering.ToString(), 0).ToString("N");
        this.lbPayTotal.Text = (Shove._Convert.StrToDouble(PayTota.ToString(), 0) == 0) ? "0.00" : Shove._Convert.StrToDouble(PayTota.ToString(), 0).ToString("N");
        this.lbDayBuy.Text = (Shove._Convert.StrToDouble(DayBuy.ToString(), 0) == 0) ? "0.00" : Shove._Convert.StrToDouble(DayBuy.ToString(), 0).ToString("N");
        this.lbHistoryBuy.Text = (Shove._Convert.StrToDouble(HistoryBuy.ToString(), 0) == 0) ? "0.00" : Shove._Convert.StrToDouble(HistoryBuy.ToString(), 0).ToString("N");
        double PlayRatio = Shove._Convert.StrToDouble(CurPlayRatio.ToString(), 0.00);
        ibRatio.Width = (Unit)(PlayRatio * 100 * 3);
        lbText.Text = (PlayRatio * 100) + "%";

        this.labTotalNumberOfCopies.Text = TotalNumberOfCopies.ToString();
        this.labDayTotalNumberOfCopies.Text = DayTotalNumberOfCopies.ToString();
    }

    private void BindanagerLoginInfo()
    {
        long ManagerCount = 0;
        string AferUser = "";
        string AfterIp = "";
        DateTime LoginAfterTime = DateTime.Now;
        string UserIp = "";
        DateTime UserLoginTime = DateTime.Now;

        if (DAL.Procedures.P_GetManagerLoginInfo(_Customer.ID, ref ManagerCount, ref AferUser, ref AfterIp, ref LoginAfterTime, ref UserIp, ref UserLoginTime) < 0)
        {
            Shove._Web.JavaScript.Alert(this.Page, "数据库连接错误");

            return;
        }

        this.lbManagerCount.Text = ManagerCount.ToString();
        this.lbAferUser.Text = AferUser;
        this.lbAfterIp.Text = AfterIp;
        this.lbLoginAfterTime.Text = LoginAfterTime.ToString();
        this.lbUserIp.Text = UserIp.ToString();
        this.lbUserLoginTime.Text = UserLoginTime.ToString();
    }
}
